<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="认领列表" libs=["table"]/>
<div class="container-div" id="_app">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <@f.form id="module-form">

            <!--我们在body中加入一个div，里面放入一个table-->
            <div style="display:none" id="test">
                <h4>高级查询</h4>
                <hr>
                <table class="table table-striped">
                    <tbody>
                    <tr>
                        <td><@ctx.i18n text = "合同名称"/>：</td>
                        <td><input type="text" class="form-control" name="title2"  placeholder="请输入生产单号"></td>
                        <td><@ctx.i18n text = "合同编号"/>：</td>
                        <td><input type="text" class="form-control" name="contractSn2"  placeholder="请输入部门"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "业务员"/>：</td>
                        <td><input type="text" class="form-control" name="saleman"  placeholder="请输入产品编号"></td>
                        <td><@ctx.i18n text = "签定公司"/>：</td>
                        <td><input type="text" class="form-control" name="company"  placeholder="请输入产品名称"></td>
                    </tr>
                    <tr>
                        <td class="select-time" colspan="4"><label>签定日期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" name="beginTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect" style="width: 150px" ><label>--</label><input type="text" name="endTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect2" style="width: 150px"></td>
                    </tr>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="2" align="center"><a class="btn btn-primary btn-rounded btn-sm" id="search" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a></td>
                        <td colspan="2" align="center"><a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a></td>
                    </tr>
                    </tfoot>
                </table>
            </div>
            <!--里面放入一个table-->

            <div class="select-list">
                <ul>
                    <li class="select-time">
                        <label>合同名称： </label>
                        <@f.input id="title" name="title"/>
                    </li>
                    <li class="select-time">
                        <label>合同编号： </label>
                        <@f.input id="contractSn" name="contractSn"/>
                    </li>
                    <li>
                        <@ctx.i18n text = "合同类型"/>：
                        <@f.select name="type" dictType="business_contract_type" blankValue="" blankLabel="所有"/>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i
                                class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a>
                        <a class="btn btn-primary btn-rounded btn-sm" id="searchall"><i
                                class="fa fa-search"></i>  <@ctx.i18n text = "高级查询"/></a>
                    </li>
                </ul>
            </div>
        </@f.form>
    </div>
    <@table id="bootstrap-table">
<@shiro.hasPermission name="contract:model:del">
    <@shiro.hasPermission name="bus:voidcontract:export">
    <a class="btn btn-warning" onclick="$.table.exportExcel()">
        <i class="fa fa-download"></i> 导出
    </a>
</@shiro.hasPermission>
<a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">
    <i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/>
</a>
</@shiro.hasPermission>
</@table>
</div>
</div>
<@footer>
<script type="text/javascript">

    var prefix = baseURL + "bus/voidcontract";

    var types = ${dict.getDictListJson('business_contract_type')};
    var payTypes = ${dict.getDictListJson('business_contract_pay_type')};
    var sta = ${dict.getDictListJson('business_contract_status')};

    $(function () {
        var options = {
            url: prefix + "/contractList3",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            clickToSelect: true,
            sortName: "id",
            delUrl: prefix + "/del",
            addUrl: prefix + "/add",
            exportUrl: prefix + "/export",
            editUrl: prefix + "/edit/{id}",//认领箱
            uniqueId: 'id', /* 唯一ID */
            modalName: "作废合同",
            onDblClickRow: onDblClickRow,
            columns: [
                {
                    title: $.i18n.prop("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {field:'title',   title: '<@ctx.i18n text = "合同名称"/>'},
                {field:'contractSn',    title: '<@ctx.i18n text = "合同编号"/>'},
                {field: 'type', title: "<@ctx.i18n text = '合同类型'/>", formatter: function(value, item, index) {
                        return $.table.selectDictLabel(types, item.type);}
                },
                {field:'company',title: '<@ctx.i18n text = "签订公司"/>'},
                {field:'signTime',title: '<@ctx.i18n text = "签订日期"/>'},
                {field:'startTime',title: '<@ctx.i18n text = "开始时间"/>'},
                {field:'endTime',title: '<@ctx.i18n text = "结束时间"/>'},
                {field:'money',title: '<@ctx.i18n text = "合同金额"/>'},
                {field:'memo',title: '<@ctx.i18n text = "备注"/>'},
                {field:'saleman',title: '<@ctx.i18n text = "业务员"/>'},
                {title:"<@ctx.i18n text = '操作'/>",align: 'left',width:54,class:'action',formatter: function(value, row, index) {
                        var actions = [];
                        if (row.status!=4){
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="toVoid('+row.id+')"><i style="color:white;" class="fa fa-trash"></i> <@ctx.i18n text = "作废"/></a> ');
                        }else{
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="doDelete('+row.id+')"><i style="color:white;" class="fa fa-trash"></i> <@ctx.i18n text = "删除"/></a> ');
                        }
                        return actions.join('');
                    }}
            ]
        };
        $.table.init(options);
    });

    /*双击行 编辑事件*/
    function onDblClickRow(row,tr,field){
        return opt.operate.edit(row.id);
    }

    function toVoid(id) {
        opt.modal.confirm("确认合同作废吗?", function() {
            opt.operate.post(prefix + "/doCancel", { "id": id});
        })
    }
    function doDelete(id) {
        opt.modal.confirm("确认要删除吗?", function() {
            opt.operate.post(prefix + "/doDelete", { "id": id});
        })
    }

</script>
<script>
    /*弹出层*/
    $('#searchall').on('click', function(){
        // layer.msg('hello');
        layer.open({
            type: 1,
            title:'组合查询',
            area: ['600px', '450px'],
            content: $("#test"),
            shade:0.0,
            btn: ['关闭'], //只是为了演示,
            btn2: function(){
                layer.closeAll();
            }
        });
    });
    /*弹出层点击查询按钮关闭弹出层*/
    $('#search').on('click',function () {
        layer.closeAll()
    });

    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect2'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
</script>
</@footer>
</@pageTheme>